package 线程课后习题;

class Spec extends Thread {
	private String name;
	public Spec(String name) {
		this.name=name;
	}
	@Override
	public void run() {
		for (int i = 1; i <= 10; i++) {
			System.out.println(this.name+ i + "号，在看病");
			try {
				Thread.sleep(200);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}

public class Test5 {
	public static void main(String[] args) {
		Thread nor = Thread.currentThread();
		nor.setPriority(Thread.MIN_PRIORITY);
		nor.setName("普通号");
		
		Spec spec = new Spec("特约病号");
		spec.setPriority(Thread.MAX_PRIORITY);
		spec.start();
		for (int i = 1; i <= 50; i++) {
			System.out.println(nor.getName()+i+"号，在看病");
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			if (i == 10) {
				try {
					spec.join();//主类不行
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
